﻿﻿
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
	String basePath = "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="/">
    <!-- 下拉框 -->
    <link rel="stylesheet" href="static/ace/css/chosen.css"/>
    <!-- jsp文件头和头部 -->
    <%@ include file="../index/top.jsp" %>
    <!-- 日期框 -->
    <link rel="stylesheet" href="static/ace/css/datepicker.css"/>
    <link rel="stylesheet" href="static/styles/base.css"/>
</head>
<body class="no-skin">

<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">

                        <!-- 检索  -->
                        <form action="businessOrders/listBusinessOrders.do" method="post" name="goodsForm" id="goodsForm">
                            <table style="margin-top:5px;">
                                <tr>
                                	<td class="center" style="padding-left:5px;"> 提交时间 </td>
                                    <td class="input-daterange"> 
                                    	<div class="dib vm pl5"><input class="span10 date-picker" name="startTime" id="startTime" value="${pd.startTime}" type="text"  style="width:88px;" placeholder="选择日期" title="选择日期"/></div>
                                    	<div class="dib vm pl5">至</div>
                                    	<div class="dib vm pl5"><input class="span10 date-picker" name="endTime" id="endTime" value="${pd.endTime}" type="text" style="width:88px;" placeholder="选择日期" title="选择日期"/></div>
                                    </td>
                                  	<td>
                                       <div class="nav-search">
											<span class="input-icon">
												<input class="nav-search-input" autocomplete="off" id="phone" type="text"
		                                               name="phone" value="${pd.phone}" placeholder="请输入手机号"/>
												<i class="ace-icon fa fa-search nav-search-icon"></i>
											</span>
                                        </div>
                                    </td>
                                    <td>
                                       <div class="nav-search">
											<span class="input-icon">
												<input class="nav-search-input" autocomplete="off" id="code" type="text"
		                                               name="code" value="${pd.code}" placeholder="请输入订单号"/>
												<i class="ace-icon fa fa-search nav-search-icon"></i>
											</span>
                                        </div>
                                    </td>
                                    <td class="center" style="padding-left:5px;">
                                        	订单状态:
                                    </td>
                                     <td style="vertical-align:top;padding-left:5px;">
                                        <select class="chosen-select form-control" name="state" id="state"
                                                data-placeholder="支付类型" style="vertical-align:top;width: 100px;">
                                            <option value="">全部</option>
                                            <option value="00" <c:if test="${pd.state=='00'}">selected</c:if>>未付款
                                            </option>
                                            <option value="02" <c:if test="${pd.state=='01'}">selected</c:if>>已付款
                                            </option>
                                            <option value="03" <c:if test="${pd.state=='05'}">selected</c:if>>已取消
                                            </option>
                                        </select>
                                    </td>
                                    <%-- <td class="center" style="padding-left:5px;">
                                        	商品种类:
                                    </td>
                                     <td style="vertical-align:top;padding-left:5px;">
                                        <select class="chosen-select form-control" name="state" id="state"
                                                data-placeholder="支付类型" style="vertical-align:top;width: 100px;">
                                            <option value="">全部</option>
                                            <option value="00" <c:if test="${pd.state=='00'}">selected</c:if>>未付款
                                            </option>
                                            <option value="02" <c:if test="${pd.state=='01'}">selected</c:if>>已付款
                                            </option>
                                            <option value="03" <c:if test="${pd.state=='05'}">selected</c:if>>已取消
                                            </option>
                                        </select>
                                    </td> --%>
                                    <td class="center" style="padding-left:5px;">
                                        	支付方式:
                                    </td>
                                     <td style="vertical-align:top;padding-left:5px;">
                                        <select class="chosen-select form-control" name="pay_mode" id="pay_mode"
                                                data-placeholder="支付类型" style="vertical-align:top;width: 100px;">
                                            <option value="">不限</option>
                                            <option value="00" <c:if test="${pd.pay_mode=='alipay'}">selected</c:if>>支付宝
                                            </option>
                                            <option value="02" <c:if test="${pd.pay_mode=='wechat'}">selected</c:if>>微信
                                            </option>
                                            <option value="03" <c:if test="${pd.pay_mode=='blance'}">selected</c:if>>余额
                                            </option>
                                        </select>
                                    </td>
                                    <c:if test="${QX.cha == 1 }">
                                        <td style="vertical-align:top;padding-left:2px;"><a class="btn btn-light btn-xs"
                                                                                            onclick="searchs();"
                                                                                            title="检索"><i
                                                id="nav-search-icon"
                                                class="ace-icon fa fa-search bigger-110 nav-search-icon blue"></i></a>
                                        </td>
                                    </c:if>
                                    <c:if test="${QX.toExcel == 1 }">
                                        <td style="vertical-align:top;padding-left:2px;"><a class="btn btn-light btn-xs"
                                                                                            onclick="toExcel();"
                                                                                            title="导出到EXCEL"><i
                                                id="nav-search-icon"
                                                class="ace-icon fa fa-download bigger-110 nav-search-icon blue"></i></a>
                                        </td>
                                    </c:if>
                                </tr>
                            </table>
                            <!-- 检索  -->
							<div style="padding-top:30px;">
								<span>订单金额总计：${orderPrice } (元)</span>
							</div>
                            <table id="simple-table" class="table table-striped table-bordered table-hover"
                                   style="margin-top:5px;">
                                <thead>
                                <tr>
                                    <th class="center" style="width:50px;">序号</th>
                                    <th class="center">订单号</th>
                                    <th class="center">用户</th>
                                    <th class="center">下单时间</th>
                                    <th class="center">商品种类</th>
                                    <th class="center">商品名称</th>
                                    <!-- <th class="center">采摘月份</th>
                                    <th class="center">期次</th> -->
                                    <th class="center">数量</th>
                                    <th class="center">单位</th>
                                    <th class="center">单价</th>
                                    <th class="center">订单金额</th>
                                    <th class="center">订单状态</th>
                                    <th class="center">支付方式</th>
                                    <!-- <th class="center">万果粮票</th> -->
                                </tr>
                                </thead>

                                <tbody id="goodlist">

                                <!-- 开始循环 -->
                                <c:choose>
                                    <c:when test="${not empty businessOrdersList}">
                                        <c:if test="${QX.cha == 1 }">
                                            <c:forEach items="${businessOrdersList}" var="businessOrders" varStatus="vs">

                                                <tr>
                                                    <td class='center' style="width: 30px;">${vs.index+1}</td>
                                                    <td class="center">${businessOrders.code }</td>
                                                    <td class="center">${businessOrders.phone }</td>
                                                    <td class="center">${businessOrders.create_time }</td>
                                                    <td class="center">${businessOrders.type }</td>
                                                    <td class="center">${businessOrders.title }</td>
                                                    <%-- <td class="center">${businessOrders.title }</td>
                                                    <td class="center">${businessOrders.pay_price }</td> --%>
                                                    <td class="center">${businessOrders.num }</td>
                                                    <td class="center">${businessOrders.unit }</td>
                                                    <td class="center">${businessOrders.price }</td>
                                                    <td class="center">${businessOrders.total_price }</td>
                                                    <td class="center"><c:if
                                                            test="${businessOrders.state=='00'}">未付款</c:if><c:if
                                                            test="${businessOrders.state=='01'}">已付款</c:if><c:if
                                                            test="${businessOrders.state=='05'}">已取消</c:if></td>
                                                    <td class="center"><c:if test="${businessOrders.pay_mode!=null}"><c:if
                                                            test="${businessOrders.pay_mode=='wechat'}">微信</c:if><c:if
                                                            test="${businessOrders.pay_mode=='alipay'}">支付宝</c:if></c:if><c:if
                                                            test="${businessOrders.pay_mode==null}">/</c:if></td>
                                                    <%-- <td class="center">${businessOrders.total_price }</td> --%>
                                                </tr>
                                            </c:forEach>
                                        </c:if>
                                        <c:if test="${QX.cha == 0 }">
                                            <tr>
                                                <td colspan="13" class="center">您无权查看</td>
                                            </tr>
                                        </c:if>
                                    </c:when>
                                    <c:otherwise>
                                        <tr class="main_info">
                                            <td colspan="13" class="center">没有相关数据</td>
                                        </tr>
                                    </c:otherwise>
                                </c:choose>
                                </tbody>
                            </table>
                            <div class="page-header position-relative">
                                <table style="width:100%;">
                                    <tr>
                                        <!-- <td style="vertical-align:top;">
                                            <a class="btn btn-mini btn-success" onclick="statistics();">账单统计</a>
                                        </td> -->
                                        <td style="vertical-align:top;">
                                            <div class="pagination"
                                                 style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </form>

                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>
    </div>
    <!-- /.main-content -->

    <!-- 返回顶部 -->
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

</div>
<!-- /.main-container -->

<!-- basic scripts -->
<!-- 页面底部js¨ -->
<%@ include file="../index/foot.jsp" %>
<!-- 删除时确认窗口 -->
<script src="static/ace/js/bootbox.js"></script>
<!-- ace scripts -->
<script src="static/ace/js/ace/ace.js"></script>
<!-- 日期框 -->
<script src="static/ace/js/date-time/bootstrap-datepicker.js"></script>
<!-- 下拉框 -->
<script src="static/ace/js/chosen.jquery.js"></script>
<!--提示框-->
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
</body>

<script type="text/javascript">
    $(top.hangge());
    
    
    var spanDateFormat = 'yyyy-mm-dd';
    $('.input-daterange').datepicker({
    	  autoclose: true,
    	  format: "yyyy-mm-dd",
    	  maxViewMode: 0,
    	});
    
    $(".zdyTime input").datepicker({
    	 format: "yyyy-mm",
    	 startView: 1,
    	 minViewMode: 1,
    	 maxViewMode: 2,
    	 language: "zh-CN",
    	 autoclose: true
	});
    
    
    
    

    //检索
    function searchs() {
    	var startTime = $("#startTime").val();//开始时间
    	var endTime = $("#endTime").val();//结束时间
        top.jzts();
        $("#goodsForm").submit();
    }

    //对接
    function editDock(id) {
        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title = "对接信息";
        diag.URL = '<%=basePath%>goods/goDock.do?goods_id=' + id;
        diag.Width = 600;
        diag.Height = 400;
        diag.CancelEvent = function () { //关闭事件
            if (diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none') {
                nextPage('${page.currentPage}');
            }
            diag.close();
        };
        diag.show();
    }


    function statistics() {
        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title = "账单统计";
        diag.URL = '<%=basePath%>bill/statistics.do';
        diag.Width = 800;
        diag.Height = 400;
        diag.CancelEvent = function () { //关闭事件
            if (diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none') {
                if ('${page.currentPage}' == '0') {
                    top.jzts();
                    setTimeout("self.location=self.location", 100);
                } else {
                    nextPage('${page.currentPage}');
                }
            }
            diag.close();
        };
        diag.show();
    }



    //检查是否为正整数
    function isInt(a) {
        var reg = /^\d+$/;
        return reg.test(a);
    }
    //复选框全选控制
    var active_class = 'active';
    $('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function () {
        var th_checked = this.checked;//checkbox inside "TH" table header
        $(this).closest('table').find('tbody > tr').each(function () {
            var row = this;
            if (th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
            else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
        });
    });

    //导出excel
    function toExcel() {
        var phone = $("#phone").val();
        var startTime = $("#startTime").val();
        var endTime = $("#endTime").val();
        var pet_name = $("#code").val();
        var LongTerm = $("#pay_mode").val();
        var type = $("#state").val();
        var pageNum = '${page.currentPage}';
        window.location.href = '<%=basePath%>businessOrders/excel.do?phone=' + phone + '&code=' + code + '&startTime=' + startTime +'&endTime=' + endTime + '&pay_mode=' + pay_mode +'&state=' + state;
    }

</script>
</html>
